<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateKfMenus extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('menus', function (Blueprint $table) {
            $table->id();
            $table->string("name", 20)->comment("菜单名");
            $table->string("alias", 50)->comment("菜单别名");
            $table->string("url", 50)->comment("前台url路径");
            $table->unsignedInteger("parentId")->default(0)->comment("父级ID");
            $table->tinyInteger("type")->default(0)->comment("终端类型，0:夸父运营后台 1:POS终端");
            $table->tinyInteger("status")->default(0)->comment("状态,0:正常,1:停用,2:其他");
            $table->tinyInteger('isDeleted')->default(0)->comment("是否删除 0：未删除，1：已删除");
            $table->tinyInteger('isShow')->default(1)->comment("是否展示 1 展示 0 不展示");
            $table->integer("createdAt")->default(0)->comment("创建时间");
            $table->integer("updatedAt")->default(0)->comment("修改时间");


            $table->index("createdAt", "idx_created_at");
            $table->index("type", "idx_type");

            $table->collation = 'utf8mb4_general_ci';
        });

        $prefix = config('other.DB_PREFIX', '');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}menus` COMMENT = '菜单表'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('menus');
    }
}
